package com.runrunfast.fxj.mapper;

import com.runrunfast.fxj.entity.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.runrunfast.fxj.form.PageForm;
import com.runrunfast.fxj.mapper.provider.SysUserMapperProvider;
import com.runrunfast.fxj.vo.PageVo;
import com.runrunfast.fxj.vo.SysUserVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 后台用户表 Mapper 接口
 * </p>
 *
 * @author 陈胤训
 * @since 2019-03-12
 */
@Repository
public interface SysUserMapper extends BaseMapper<SysUser> {

    List<SysUser> findOne();


    @SelectProvider(type = SysUserMapperProvider.class,method = "getPageUserList" )
    List<SysUser> getPageUserList(@Param("pageVo") PageForm pageVo, @Param("username") String username);

    @Select("<script>  " +
            "select sys_user_id,phone,user_name,mail,balance,status,create_time,update_time" +
            " from sys_user <if test='username != null'> where user_name like concat('%',#{username},'%') </if>  order by sys_user_id asc  limit #{pageVo.current},#{pageVo.size}" +
            "</script> ")
    List<SysUserVo> getPageUserList1(@Param("pageVo") PageForm pageVo, @Param("username") String username);
}
